package com.itxx.allTools.homeWork.demo;

public  class Student {
    /* 请按标准格式定义一个“学生类”，它有三个属性：姓名、性别、年龄
     请编写测试类，创建两个“学生对象”并为它们的属性赋值，并能比较两个对象的所有属性值是否完全相等。*/
    private String name;
    private String gender;
    private int age;

    @Override
    public String toString() {
        return "Student{" +
                "name='" + name + '\'' +
                ", gender='" + gender + '\'' +
                ", age=" + age +
                '}';
    }

    @Override
    public boolean equals(Object o) {
        if (this == o) return true;
        if (o == null || getClass() != o.getClass()) return false;

        Student student = (Student) o;

        if (age != student.age) return false;
        if (name != null ? !name.equals(student.name) : student.name != null) return false;
        return gender != null ? gender.equals(student.gender) : student.gender == null;
    }

    @Override
    public int hashCode() {
        int result = name != null ? name.hashCode() : 0;
        result = 31 * result + (gender != null ? gender.hashCode() : 0);
        result = 31 * result + age;
        return result;
    }

    public String getName() {
        return name;
    }

    public void setName(String name) {
        this.name = name;
    }

    public String getGender() {
        return gender;
    }

    public void setGender(String gender) {
        this.gender = gender;
    }

    public int getAge() {
        return age;
    }

    public void setAge(int age) {
        this.age = age;
    }

    public Student(String name, String gender, int age) {
        this.name = name;
        this.gender = gender;
        this.age = age;
    }

    public Student() {
    }


    static class Test {
        /* 请按标准格式定义一个“学生类”，它有三个属性：姓名、性别、年龄
     请编写测试类，创建两个“学生对象”并为它们的属性赋值，并能比较两个对象的所有属性值是否完全相等。*/
        public static void main(String[] args) {


        Student stu1 = new Student("张三","男",23);
        Student stu2 = new Student("张三","男",23);
        Student stu3 = new Student("李四","男",23);

            System.out.println(stu1.equals(stu2));
            System.out.println(stu1.equals(stu3));
        }
}
}